﻿<%
    page inherit Index;
    page route "search";

    using System;
    using System.Linq;
    using MongoDB.Driver;
    using MongoDB.Driver.Builders;
%>


%override Body
<div class="content" style="background-color:{%rand_color()%};">
    <ul style="text-align:left">
        <form action="." method="post">
            <label><h2>Search:</h2></label><input name="q" type="text" size="56" /><input type="submit" value="Go" />
            <div class="spacer"></div>
            <div class="result">
                % var res = Database.News.Find(Query.EQ("Tags",Request["q"]));

                %if(res.Count()==0)
                    <h2>Nothing found</h2>
                %else
                    <ul>
                        %foreach (var news in res)
                            <li>
                                <h2>
                                    <a href="{%news.Link%}">
                                        {%news.Title%}
                                    </a>
                                </h2>
                            </li>   
                        %end foreach
                    </ul>
                %end if
            </div>
        </form>
    </ul>
</div>

%end override 